package com.gxar.marketdelivery.interfaces.web.controller;

import com.gxar.marketdelivery.application.facade.DeliveryFacade;
import com.gxar.marketdelivery.interfaces.web.param.MultiResSlotWithKeyParam;
import com.gxar.marketdelivery.interfaces.web.param.SingleResSlotWithKeyParam;
import com.gxar.marketdelivery.interfaces.web.result.APIResult;
import com.gxar.marketdelivery.interfaces.web.result.CDeliveryResSlotResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nice
 * @version 1.0
 * @created 2023/8/2.
 */
@RestController
@RequestMapping("/api/v1/delivery/client")
@Api(tags = "投放C端API文档")
public class DeliveryController {

    @Autowired
    protected DeliveryFacade deliveryFacade;

    @CrossOrigin
    @PostMapping("/getResSlotByKey")
    @ApiOperation(value = "根据资源位Key查询单个资源位下的投放信息", response = CDeliveryResSlotResult.class)
    public APIResult<CDeliveryResSlotResult> getResSlotByKey(@RequestBody SingleResSlotWithKeyParam param) {
        return new APIResult<>(deliveryFacade.getResSlotBySlotKey(param));
    }

    @CrossOrigin
    @PostMapping("/getResSlotByKeys")
    @ApiOperation(value = "根据资源位Key列表查询单个资源位下的投放信息", response = CDeliveryResSlotResult.class)
    public APIResult<List<CDeliveryResSlotResult>> getResSlotByKeys(@RequestBody MultiResSlotWithKeyParam param) {
        return new APIResult<>(deliveryFacade.getResSlotBySlotKeys(param));
    }
}
